var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/help/CalcSubProjectHelp/index.tsx
var CalcSubProjectHelp_exports = {};
__export(CalcSubProjectHelp_exports, {
  CalcSubProjectHelp: () => CalcSubProjectHelp,
  MultipleCalcSubProjectHelp: () => MultipleCalcSubProjectHelp,
  default: () => CalcSubProjectHelp_default
});
module.exports = __toCommonJS(CalcSubProjectHelp_exports);
var import_react = __toESM(require("react"));
var import_functionalComponent = require("../../../functionalComponent");
var import_util = require("../../../util");
var import_common = require("../common");
var import_HelpContent = require("./HelpContent");
var import_HelpContentSimple = require("./HelpContentSimple");
var CalcSubProjectHelp = (0, import_util.compHoc)((props) => {
  const cacheHelpInfo = (0, import_react.useRef)({ data: null, p: null });
  const {
    valueField = "projCode",
    labelField = "projectName",
    showTree = true,
    displayField,
    userCodeField,
    title,
    multiple = false,
    modalProps,
    footer,
    params: treeParams,
    treeRequest,
    beforeRequest: beforeTreeRequest,
    calcSubProjectRequest,
    calcSubProjectParams = {},
    columns,
    onBeforeOpen,
    treeProps,
    engineeringProjectCode,
    ...others
  } = props;
  const helpId = "calcSubProject";
  const otherProps = others;
  otherProps.onBeforeOpen = (0, import_util.useRefCallback)(async () => {
    const [status, helpInfo] = await (0, import_common.getHelpBeforeOpen)({ onBeforeOpen, cacheHelpInfo });
    if (import_util.iup.isObject(helpInfo)) {
      return helpInfo;
    }
    return status;
  });
  otherProps.request = (0, import_util.useRefCallback)(
    async ({ pageIndex, pageSize, keyword, treeNodes, containLowOrgUser = false, selectId }) => {
      var _a;
      const data = {
        ...calcSubProjectParams,
        containLowOrgUser,
        engineeringProjectFlg: !selectId,
        pageNum: pageIndex,
        pageSize
      };
      keyword && (data.query = keyword);
      selectId && (data.engineeringProjectNo = selectId);
      showTree && (data.orgNo = (_a = treeNodes == null ? void 0 : treeNodes[0]) == null ? void 0 : _a.code);
      if (calcSubProjectRequest) {
        return await calcSubProjectRequest(data);
      }
      const res = await import_util.iup.request.body({
        url: "/basedata/project/getProjectPages",
        data
      });
      if ((res == null ? void 0 : res.code) === 0)
        return res == null ? void 0 : res.data;
      return { list: [], total: 0 };
    }
  );
  otherProps.valueField = valueField;
  otherProps.userCodeField = userCodeField;
  otherProps.labelField = labelField || displayField;
  otherProps.contentParams = {
    footer,
    helpId,
    showTree,
    multiple,
    valueField,
    labelField: otherProps.labelField,
    treeProps: {
      params: treeParams,
      beforeRequest: beforeTreeRequest,
      treeRequest,
      ...treeProps
    },
    columns: columns ?? [
      { dataIndex: "projCode", title: "项目编码", width: multiple ? 90 : 120 },
      { dataIndex: "projectName", title: "项目名称", tooltip: true },
      { dataIndex: "belongOrgName", title: "所属组织", tooltip: true },
      { dataIndex: "projManager", title: "项目经理", tooltip: true },
      { dataIndex: "projAddress", title: "项目地址", tooltip: true },
      { dataIndex: "projScaleName", title: "项目规模", tooltip: true },
      { dataIndex: "engineImportanceCateName", title: "工程重要性类别", tooltip: true },
      { dataIndex: "engineCateName", title: "工程类别", tooltip: true }
    ]
  };
  if (title) {
    otherProps.contentParams.helpTitle = title;
  }
  if (onBeforeOpen) {
    otherProps.cache = false;
  }
  const { width, height } = (0, import_util.getGlobalConfig)().default.helpConfig;
  if (engineeringProjectCode) {
    otherProps.request = (0, import_util.useRefCallback)(async ({ pageIndex, pageSize, containLowOrgUser = false }) => {
      const data = {
        ...calcSubProjectParams,
        containLowOrgUser,
        engineeringProjectFlg: false,
        engineeringProjectNo: engineeringProjectCode,
        pageNum: pageIndex,
        pageSize
      };
      const res = await import_util.iup.request.body({ url: "/basedata/project/getProjectPages", data });
      if ((res == null ? void 0 : res.code) === 0)
        return res == null ? void 0 : res.data;
      return { list: [], total: 0 };
    });
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_functionalComponent.BaseHelp,
    {
      ...otherProps,
      modal: true,
      helpContent: engineeringProjectCode ? import_HelpContentSimple.HelpContentSimple : import_HelpContent.HelpContent,
      multiple,
      modalProps: { width, height, ...modalProps }
    }
  );
}, "CalcSubProjectHelp");
var MultipleCalcSubProjectHelp = import_react.default.forwardRef(
  (props, ref) => {
    return /* @__PURE__ */ import_react.default.createElement(CalcSubProjectHelp, { ...props, ref, multiple: true });
  }
);
var CalcSubProjectHelp_default = CalcSubProjectHelp;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CalcSubProjectHelp,
  MultipleCalcSubProjectHelp
});
